#include "app_buffer.h"
#include "log.h"

int main(int argc, char const *argv[])
{
    // 1 初始化n缓存
    buffer_t *buffer = app_buffer_init(16);

    // 2 添加数据
    app_buffer_write(buffer, "01234567", 8);
    app_buffer_write(buffer, "9abcd", 5);

    // 3 读取数据
    char read_buff[100] = {0};
    int read_size = app_buffer_read(buffer, read_buff, 100);
    log_info("read_buff:%.*s", read_size, read_buff);

    // 4 读取数据
    char read_buff2[100] = {0};
    read_size = app_buffer_read(buffer, read_buff2, 100);
    log_info("read_buff:%.*s", read_size, read_buff2);

    // 5 添加数据
    app_buffer_write(buffer, "ef0123456", 9);

    // 6 读取数据
    char read_buff3[10] = {0};
    read_size = app_buffer_read(buffer, read_buff3, 10);
    log_info("read_buff:%.*s", read_size, read_buff3);

    // 7 写入数据(失败)
    app_buffer_write(buffer, "1111111111111111111", 19);

    return 0;
}
